#include "OracleIntervalType.h"

OracleIntervalType_ptr OracleIntervalType::YEAR = OracleIntervalType_ptr(new OracleIntervalType(1ULL << 0, make_string_ptr("YEAR")));
OracleIntervalType_ptr OracleIntervalType::MONTH = OracleIntervalType_ptr(new OracleIntervalType(1ULL << 1, make_string_ptr("MONTH")));
OracleIntervalType_ptr OracleIntervalType::DAY = OracleIntervalType_ptr(new OracleIntervalType(1ULL << 2, make_string_ptr("DAY")));
OracleIntervalType_ptr OracleIntervalType::HOUR = OracleIntervalType_ptr(new OracleIntervalType(1ULL << 3, make_string_ptr("HOUR")));
OracleIntervalType_ptr OracleIntervalType::MINUTE = OracleIntervalType_ptr(new OracleIntervalType(1ULL << 4, make_string_ptr("MINUTE")));
OracleIntervalType_ptr OracleIntervalType::SECOND = OracleIntervalType_ptr(new OracleIntervalType(1ULL << 5, make_string_ptr("SECOND")));

OracleIntervalType::OracleIntervalType(uint64_t mask, string_ptr name)
{
  this->mask = mask;
  this->name = name;
}

OracleIntervalType_ptr OracleIntervalType::valueOf(string_ptr name)
{
  if (name->c_str() == "YEAR")
  {
    return OracleIntervalType::YEAR;
  }
  else if (name->c_str() == "MONTH")
  {
    return OracleIntervalType::MONTH;
  }
  else if (name->c_str() == "DAY")
  {
    return OracleIntervalType::DAY;
  }
  else if (name->c_str() == "HOUR")
  {
    return OracleIntervalType::HOUR;
  }
  else if (name->c_str() == "MINUTE")
  {
    return OracleIntervalType::MINUTE;
  }
  else if (name->c_str() == "SECOND")
  {
    return OracleIntervalType::SECOND;
  }
  else
  {
    return nullptr;
  }
}